#include <iostream>
#include <string>

using namespace std;

// 1957. 删除字符使字符串变好
// https://leetcode.cn/problems/delete-characters-to-make-fancy-string/description/?envType=daily-question&envId=2025-07-21

class Solution1
{
public:
    string makeFancyString(string s)
    {
        char preCh = s[0];
        string ans;
        int sum = 0;
        for (int i = 1; i < s.size(); ++i)
        {
            char curCh = s[i];
            if (curCh == preCh)
            {
                sum += 1;
            }
            else
            {
                if (sum >= 2)
                {
                    ans.append(2, preCh);
                }
                else
                {
                    ans.append(1, preCh);
                }
                preCh = curCh;
                sum = 1;
            }
        }

        if (sum >= 2)
        {
            ans.append(2, preCh);
        }
        else
        {
            ans.append(1, preCh);
        }

        return ans;
    }
};

class Solution
{
public:
    string makeFancyString(string s)
    {
        string ans;
        int cnt = 0;
        for (int i = 0; i < s.size(); i++)
        {
            cnt++;
            if (cnt < 3)
            {
                ans += s[i];
            }
            if (i != s.size() - 1 && cnt >= 3 && s[i] != s[i + 1])
            {
                cnt = 0;
            }
        }
        return ans;
    }
};

int main()
{
    return 0;
}